//
//  YIem_FindDetail_Time_ViewController.m
//  B段_开眼
//
//  Created by YIem on 16/4/25.
//  Copyright © 2016年 Howie. All rights reserved.
//

#import "YIem_FindDetail_Time_ViewController.h"

@interface YIem_FindDetail_Time_ViewController ()<UITableViewDataSource, UITableViewDelegate>
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) NSMutableArray *dataArr;
@end
@implementation SDWebImageManager (cache)

- (BOOL)memoryCachedImageExistsForURL:(NSURL *)url {
    NSString *key = [self cacheKeyForURL:url];
    return ([self.imageCache imageFromMemoryCacheForKey:key] != nil) ?  YES : NO;
}

@end
@implementation YIem_FindDetail_Time_ViewController


- (void)viewDidLoad {
    [super viewDidLoad];

    self.dataArr = [NSMutableArray array];
    self.automaticallyAdjustsScrollViewInsets = NO;
    self.view.backgroundColor = [UIColor whiteColor];
    
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 104, self.view.frame.size.width, self.view.frame.size.height - 104) style:UITableViewStylePlain];
//    self.tableView.backgroundCorlor = [UIColor greenColor];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
   self.tableView.separatorStyle = UITableViewCellSelectionStyleNone;
    [self.view addSubview:self.tableView];
    
    [self.tableView registerClass:[YIem_FindDetail_Time_TableViewCell class] forCellReuseIdentifier:@"YIem_FindDetail_Time_TableViewCell"];
   
     [self dataBase];
    
}


-(void)setUrlStr:(NSString *)urlStr
{
    _urlStr = urlStr;
    [self dataBase];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.dataArr.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    YIem_FindDetail_Time_TableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"YIem_FindDetail_Time_TableViewCell" forIndexPath:indexPath];
    
    cell.model = self.dataArr[indexPath.row];
    
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return hEIGHT;
}
//- (void)tableView:(UITableView *)tableView willDisplayCell:(YIem_FindDetail_Time_TableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
//{
//    EveryCellModel *model = self.dataArr[indexPath.row];
//    if (![[SDWebImageManager sharedManager] memoryCachedImageExistsForURL:[NSURL URLWithString:model.feed]]) {
//        
//        CATransform3D rotation;
//        rotation = CATransform3DMakeTranslation(0, 50, 20);
////        rotation = CATransform3DMakeRotation( M_PI_4 , 0.0, 0.7, 0.4);       //逆时针旋转
//        rotation = CATransform3DScale(rotation, 0.9, .9, 1);
//        
//        rotation.m34 = 1.0/ -600;
//        
//        cell.layer.shadowColor = [[UIColor blackColor]CGColor];
//        cell.layer.shadowOffset = CGSizeMake(10, 10);
//        cell.alpha = 0;
//        
//        cell.layer.transform = rotation;
//        
//        [UIView beginAnimations:@"rotation" context:NULL];
//        //旋转时间
//        [UIView setAnimationDuration:0.6];
//        cell.layer.transform = CATransform3DIdentity;
//        cell.alpha = 1;
//        cell.layer.shadowOffset = CGSizeMake(0, 0);
//        [UIView commitAnimations];
//  
//    }
//    [cell cellOffset];
//    cell.model = model;
//}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

// 解析
- (void)dataBase
{


    [YIem_FindDetailViewModel getDataWithPage:self.urlStr andUpdate:YES andBlock:^(NSMutableArray *arr, NSString *str, NSString *aa) {
//        NSLog(@"%@", arr);
        self.dataArr = arr;
//        NSLog(@"%@", self.dataArr);
        
        [self.tableView reloadData];
    }];
    
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
